<?php 
require_once 'init.php';
require_once 'ckLogin.php';
require_once 'dbClasses'.DIRECTORY_SEPARATOR.'config.php';
require_once 'dbClasses'.DIRECTORY_SEPARATOR.'dbConn.php';
$db = new dbConn();
//定义表名
define("TABLENAME","content");
define("TABLENAME1","priceninepointnine");
define("TABLENAME1","admin");
define("TABLENAME2","category");
define("VIEWNAME", "v_content_union_9p9");
//提交处理
if(strtoupper($_SERVER['REQUEST_METHOD'])=='POST'){
	$contentID=$_POST['contentID'];
	$title = $_POST['title'];
	$desc=htmlspecialchars($_POST['description']);
	$updater_2 = $_POST['updater_2'];
	$originalPrice = $_POST['originalPrice'];
	$currentPrice = $_POST['currentPrice'];
	$goodsUrl = $_POST['goodsUrl'];
	$cate_id = $_POST['cate_id'];
	//
	$publishDate = $_POST['publishDate'];
	$sort = $_POST['sort'];
	$picture = $_POST['taobao_item_img'];
	$saledNum = $_POST['saledNum']?$_POST['saledNum']:0;
	$commission = $_POST['commission'];
	$pic_1 = $_POST["pic_1"];
	//手动录入用1，根据id接口用2，默认2
	$comefrom = $_POST['comefrom']?$_POST['comefrom']:2;
	//新增
	$startTime = strtotime($_POST['startTime']);
	$endTime = strtotime($_POST['endTime']);
	
	if(empty($contentID)){
		$db->sql="INSERT INTO content(`desc`,updater,goodsUrl,title,originalPrice,currentPrice,picture,publishDate,sort,comefrom) VALUES('".$desc."' , '".$updater_2."' , '".$goodsUrl."' , '".$title."' , '".$originalPrice."' , '".$currentPrice."' , '".$picture."' , '".$publishDate."' ,'".$sort."' , ".$comefrom.")";
		$db->doExecute();
?>
	<script type="text/javascript">
		this.location.replace('insertNew.php');
	</script>
<?php 
	}else{
		$db->sql="SELECT id,goodsID,updater,publishDate FROM ";
		if($comefrom==2) $db->sql .= TABLENAME; elseif ($comefrom==3) $db->sql .= TABLENAME1; 
		$db->sql.=" WHERE  id = {$contentID} ";
		$goodsInfo = $db->doResult2();
		if (empty($goodsInfo['goodsID'])) {
			die("商品id为空");
		}
		//判断15天内是否有其他人推荐该商品
		/* $db->sql="SELECT count(id) cid,IF( (publishDate>=DATE(DATE_SUB('{$publishDate}', INTERVAL 15 DAY)) AND (publishDate<='{$publishDate}') ) ,1,0) cLT,IF( (publishDate<=DATE(DATE_ADD('{$publishDate}', INTERVAL 15 DAY)) AND (publishDate>'{$publishDate}') ),1,0) cGT FROM content WHERE goodsID = {$goodsInfo['goodsID']} AND publishDate>=DATE(DATE_SUB('{$publishDate}', INTERVAL 15 DAY)) AND publishDate<=DATE(DATE_ADD('{$publishDate}', INTERVAL 15 DAY)) AND id != {$contentID} AND updater != '{$goodsInfo['updater']}' AND isDel!=1";
		$goodsInfoTongJi = $db->doResult2();
		//var_dump($goodsInfoTongJi);
		$noAccess=0;
		if ($goodsInfoTongJi['cid']>0) {
			if ($goodsInfoTongJi['cLT']>0) {
				$noAccess=1;
			}
			if ($goodsInfoTongJi['cGT']>0) {
				$noAccess=2;
			}
		} */
		/* //判断该商品是否已经被人录用了
		$db->sql="SELECT COUNT(c.id) FROM content c RIGHT JOIN admin a ON c.updater=a.userName AND a.isActive=1 WHERE c.publishDate >= '2013-04-01' AND c.goodsID = '{$goodsInfo['goodsID']}' AND c.updater != '{$goodsInfo['updater']}' UNION ".
			 	 "SELECT COUNT(c.id) num FROM priceninepointnine c RIGHT JOIN admin a ON c.updater=a.userName AND a.isActive=1 WHERE c.publishDate >= '2013-04-01' AND c.goodsID = '{$goodsInfo['goodsID']}' AND c.updater != '{$goodsInfo['updater']}'";
		$goodsInfoTongJi2 = $db->doResultList2();
		foreach ($goodsInfoTongJi2 as $i){
			//var_dump($i)
			$num+=$i['num'];
		}
		$noAccess2=0;
		if ($num>0) {
			$noAccess2=1;
		} */
		//if (strtotime($publishDate)>=strtotime(date("Y-m-d")) || strtotime($goodsInfo['publishDate'])==strtotime($publishDate)) {
			//if ($noAccess==0 && $noAccess2==0) {
				if ($comefrom==1 || $comefrom==2) {
					if($comefrom==1){
						$db->sql="UPDATE ".TABLENAME." SET `desc` = '".$desc."' , updater = '".$updater_2."' , goodsUrl = '".$goodsUrl."' , title = '".$title."' , originalPrice = '".$originalPrice."' , currentPrice = '".$currentPrice."' , picture = '".$pic_1."' , publishDate = '".$publishDate."' , sort = ".$sort." , cateID = ".$cate_id." , saledNum = ".$saledNum." , commission = ".$commission." WHERE id = ".$contentID;
						$db->doExecute();
					}elseif($comefrom==2){
						$db->sql="UPDATE ".TABLENAME." SET `desc` = '".$desc."' , updater = '".$updater_2."' , goodsUrl = '".$goodsUrl."' , title = '".$title."' , originalPrice = '".$originalPrice."' , currentPrice = '".$currentPrice."' , picture = '".$pic_1."' , ";
						if(!empty($picture)){
							$db->sql .= "picture = '".$picture."' , ";
						}
						$db->sql .= "publishDate = '".$publishDate."' , sort = ".$sort." , cateID = ".$cate_id." , saledNum = ".$saledNum." , commission = ".$commission." WHERE id = ".$contentID;
						//echo $db->sql;die();
						$db->doExecute();
					}
					//操作记录
					$db->sql = "INSERT INTO goodschange (changeid,`table`,goodsid,oldsaletime,operate,updater,changetime) VALUES({$contentID},'".TABLENAME."',{$goodsInfo['goodsID']},'{$goodsInfo["publishDate"]}','修改','{$_SESSION["userName"]}',".time().")";
					$db->doExecute();
				}elseif($comefrom==3){
        			$db->sql="UPDATE ".TABLENAME1." SET `desc` = '".$desc."' , updater = '".$updater_2."' , goodsUrl = '".$goodsUrl."' , title = '".$title."' , originalPrice = '".$originalPrice."' , currentPrice = '".$currentPrice."' , publishDate = '".$publishDate."' , sort = ".$sort." , saledNum = ".$saledNum." , commission = ".$commission." , startTime = ".$startTime." , endTime = ".$endTime." , picture ='".$pic_1."',cateID = {$cate_id} WHERE id = ".$contentID;
        			$db->doExecute();
        			$db->sql="SELECT id,goodsID,updater,publishDate FROM ".TABLENAME1." WHERE  id = {$contentID} ";
        			$goodsInfo = $db->doResult2();
        			//操作记录
        			$db->sql = "INSERT INTO goodschange (changeid,`table`,goodsid,oldsaletime,operate,updater,changetime) VALUES({$contentID},'".TABLENAME1."',{$goodsInfo['goodsID']},'{$goodsInfo["publishDate"]}','修改','{$_SESSION["userName"]}',".time().")";
        			$db->doExecute();
		        }else{
					die("失败的，没comefrom");
				}
				
			//}
		//}else{
		//	$publishDateError = true;
		//}
		if ($_GET['cateid']==='9p9') {
			$db->sql="SELECT `status` FROM priceninepointnine WHERE id = ".$contentID;
		}else{
			$db->sql="SELECT `status` FROM content WHERE id = ".$contentID;
		}
		$status = $db->doResultOne();
		if($status==0){
			?>
				<script type="text/javascript">
				
					this.location.replace('insertNew.php?noaccess=<?php echo $noAccess;?>&publishDateError=<?php if($publishDateError) echo 1;?>');
				</script>
			<?php 
		}
	}
	
}
//条件
$where = '';
//$where = "WHERE p.`status`!=0 AND p.`isDel`!=1 ";
if(!empty($_GET['startTime']) || !empty($_GET['endTime']) || !empty($_GET['updater']) || !empty($_GET['cateid']) || !empty($_GET['goodsid'])){
	if(!empty($_GET['startTime'])) $where.= "AND p.publishDate>='".$_GET['startTime']."' ";
	if(!empty($_GET['endTime'])) $where.= "AND p.publishDate<='".$_GET['endTime']."' ";
	if(!empty($_GET['updater'])) $where.= "AND p.updater='".$_GET['updater']."' ";
	if(!empty($_GET['cateid'])) if($_GET['cateid']==='9p9') $where.= "AND p.fromtable='NPN' "; else $where.= " AND p.fromtable='JX' AND c1.id={$_GET['cateid']} ";
	if(!empty($_GET['goodsid'])) $where.= "AND p.goodsID='{$_GET['goodsid']}' ";
	
}
//排序publishDate Updater shared collected
if(!empty($_GET['sort'])){
	$sortarray = explode('_', $_GET['sort']);
	$order = "p.".$sortarray[0]." ".$sortarray[1].",";
}else{
	$order = '';
}
//总条数
$db->sql="SELECT count(p.id) count_id FROM ".VIEWNAME." p LEFT JOIN admin a ON a.userName = p.updater LEFT JOIN category c1 ON c1.id = p.cateID LEFT JOIN category99 c2 ON c2.id = p.cateID WHERE 1=1 {$where}";
$count = $db->doResultOne();
//分页
if(empty($_GET['page'])){$page = 1;}else{$page=$_GET['page'];}
if(empty($_GET['pagesize'])){$pagesize = PAGESIZE;}
else{$pagesize = $_GET['pagesize'];}
$pageInfo = page($count, $pagesize, $page);
$maxPage = $pageInfo['maxPage'];
$start = $pageInfo['start'];
$pages = $pageInfo['pages'];

$db->sql="SELECT p.*,a.nickName,IF(p.fromtable = 'JX',c1.cate,c2.cate) catename FROM v_content_union_9p9 p LEFT JOIN admin a ON a.userName = p.updater LEFT JOIN category c1 ON c1.id = p.cateID LEFT JOIN category99 c2 ON c2.id = p.cateID WHERE 1=1 {$where} ORDER BY p.publishDate DESC ,p.fromtable ASC ,p.sort ASC LIMIT ".$start.",".$pagesize;
$pictures = $db->doResultList2();
//分类
$db->sql="SELECT * FROM category ORDER BY `sort`";
$category = $db->doResultList2();
//分类
$db->sql="SELECT * FROM category99 ORDER BY `sort`";
$category99 = $db->doResultList2();
//var_dump($pictures);die();
//url
$url= "?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid']."&cateid=".$_GET['cateid']."&sort=".$_GET['sort'];
$url2="?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid']."&cateid=".$_GET['cateid'];
$url3="?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid'];
$url4="?updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid'];

$admins = getAdmin($db);
//今日商品数
$db->sql = "SELECT COUNT(id) FROM `content` WHERE publishDate = date(now()) AND `status`=1 AND `isDel`!=1 ";
$todayGoodsNum = $db->doResultOne();
foreach ($category as $key => $item){
	$db->sql = "SELECT COUNT(id) FROM `content` WHERE publishDate = date(now()) AND `status`=1 AND `isDel`!=1 AND `cateID` = {$item['id']}";
	$category[$key]['num'] = $db->doResultOne();
}
//9kuai9数量
$db->sql = "SELECT COUNT(id) FROM `priceninepointnine` WHERE publishDate = date(now()) AND `status`=1 AND `isDel`!=1 ";
$todayNPNNum = $db->doResultOne();
//19kuai9数量
/* $db->sql = "SELECT COUNT(id) FROM `priceninetenpointnine` WHERE publishDate = date(now()) AND `status`=1 AND `isDel`!=1 ";
$todayNTPNNum = $db->doResultOne(); */
//var_dump($admins);
//用户列表
function getAdmin($db){
	$db->sql = "SELECT * FROM admin WHERE id != 1 AND type=2";
	return $admins = $db->doResultList2();
}
//分页
function page($total,$size,$page){
	//最大页数
	if($total%$size==0){
		$maxPage = $total/$size;
	}else{
		$maxPage = (int)($total/$size)+1;
	}
	//开始条数
	$start = ($page-1)*$size;
	//分页
	if($maxPage>=5){
		if($page<=2){
			$pages=array(1,2,3,4,5);
		}elseif($page>=($maxPage-1)){
			$pages=array($maxPage-4,$maxPage-3,$maxPage-2,$maxPage-1,$maxPage);
		}else{
			$pages=array($page-2,$page-1,$page,$page+1,$page+2);
		}
	}else{
		for($i=1;$i<=$maxPage;$i++){
			$pages[]=$i;
		}
	}
	if($page<=1){$previous=1;}else{$previous=$page-1;} 
	if($page>=$maxPage) {$next = $maxPage;}else{ $next = $page+1;}
	return array('maxPage'=>$maxPage,'start'=>$start,'pages'=>$pages,'previous'=>$previous,'next'=>$next);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simpla Admin</title>
<!--                       CSS                       -->
<!-- Reset Stylesheet -->
<link rel="stylesheet" href="resources/css/reset.css" type="text/css"
	media="screen" />
<!-- Main Stylesheet -->
<link rel="stylesheet" href="resources/css/main.css" type="text/css"
	media="screen" />
<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
<link rel="stylesheet" href="resources/css/invalid.css" type="text/css"
	media="screen" />
<!-- Colour Schemes
		Default colour scheme is green. Uncomment prefered stylesheet to use it.
		<link rel="stylesheet" href="resources/css/blue.css" type="text/css" media="screen" />
		<link rel="stylesheet" href="resources/css/red.css" type="text/css" media="screen" />  
		-->
<!-- Internet Explorer Fixes Stylesheet -->
<!--[if lte IE 7]>
			<link rel="stylesheet" href="resources/css/ie.css" type="text/css" media="screen" />
		<![endif]-->
<!--                       Javascripts                       -->
<!-- jQuery -->
<script type="text/javascript" src="resources/scripts/jquery-1.7.2.min.js"></script>

<script type="text/javascript">
$(function($) {
	$(".editbutton").click(function(){
		var id = $(this).data('id');
		var fromtable = $(this).data("fromtable");
		var table = "content";
		if(fromtable=='JX') {
			table = "content";
			$("#startTime").parent("span").hide();
			$("#endTime").parent("span").hide();
			$("#updatecatebyidHtml").html($("#updatecatebyid_Html1").html());
			$("#updatecatebyidHtml>select").show();
		}
		if(fromtable=='NPN') {
			table = "priceninepointnine";
			$("#startTime").parent("span").show();
			$("#endTime").parent("span").show();
			$("#updatecatebyidHtml").html($("#updatecatebyid_Html2").html());
			$("#updatecatebyidHtml>select").show();
			$("#comefrom").val(3);
		}
		

		$("#pic_id").val(id);
		//获取描述
		$.ajax({
			   type: "GET",
			   //url: "getDesc.php",
			   //data: "id="+$(this).attr('id'),
			   url: "youpinAjax.php",
			   data: "act=VConUnionNpnEdit&id="+id+"&table="+table,
			   dataType: "json",
			   success: function(date){
				   //alert( date.cateID);
				   $("#description").html(date.desc);
				   $("#title").val(date.title);
				   $("#goodsUrl").val(date.goodsUrl);
				   $("#updater_2").val(date.updater);
				   $("#contentID").val(date.id);
				   $("#originalPrice").val(date.originalPrice); //
				   $("#currentPrice").val(date.currentPrice);
				   if(parseInt($("#comefrom").val())!=3) $("#comefrom").val(date.comefrom);
				   $("#sort").val(date.sort);
				   $("#publishDate").val(date.publishDate);
				   $("#updater_2 option").attr("selected",false);
				   $("#cate_id option").attr("selected",false);
				   $(".cate-option-"+date.cateID).attr("selected","selected");
				   $("#update-option-"+date.aid).attr("selected","selected");
				   $("#saledNum").val(date.saledNum);
				   $("#commission").val(date.commission);
				   $("#pic_1").val(date.picture);
				   //
				   $("#startTime").val(date.startTime1);
				   $("#endTime").val(date.endTime1);
				   $("#message_click").click();
			   }
		});
	});
	//删除商品
	$(".delbutton").click(function(){
		var id = $(this).data("id");
		//处理的表
	    var fromtable = $(this).data("fromtable");
		var table = "content";
		if(fromtable=='JX') {
			table = "content";
		}
		if(fromtable=='NPN') {
			table = "priceninepointnine";
		}
		
		if(confirm('你确定要删除该商品！')){
			//alert($(this).parent().parent().children("td:eq(1)").text());
			_this = $(this).parents("tr");
			//删除数据
			$.ajax({
				   type: "GET",
				   url: "youpinAjax.php",
				   data: "id="+$(this).data("id")+"&act=VConUnionNpnDel&table=<?php echo TABLENAME;?>",
				   async: false,
				   success: function(){
						alert('删除成功');
						_this.hide();
					}
			} );
		}
	});
	
	//商品上下架
	$(".isSalebutton").click(function(){
		var _this = $(this);
		var id = _this.data("id");
		var status = _this.data("status");
		if(status==1) {var word = "是否下架该商品？";}
		if(status==2) {var word = "是否上架该商品？";}
	    //处理的表
	    var fromtable = $(this).data("fromtable");
		var table = "content";
		if(fromtable=='JX') {
			table = "content";
		}
		if(fromtable=='NPN') {
			table = "priceninepointnine";
		}
		//alert(id);return false;
		if(confirm(word)){
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "id="+id+"&act=isSale&table="+table+"&",
				dataType: "html",
				success: function(rs){
					if(rs==1) {_this.css("color","#57a000").text("上架中");alert("上架成功！！");};
					if(rs==2) {_this.css("color","#000").text("下架中");alert("下架成功！！");};
					_this.data("status",rs);
				}
			});
		}
	});
	//多数据操作
	$(".xiugai").click(function(){
		//alert($("#caozuo option:selected").val());
			var text="";  
	        $("input[name=picSel]").each(function() {  
	            if ($(this).attr("checked")) {  
	                text += ","+$(this).val();  
	            }  
	        });
	        //alert(text);
	        window.location.replace('moreEdit.php?ids='+text);
		
	});
	//导出
	$("#download").click(function(){
		var startTime = $('#startTime').val();
		var endTime   = $('#endTime').val();
		var updater = $("#updater").val();
		//var pagesize = $("#pagesize").val();
		var cateid = $("#cateid").val();
		
		if(startTime && endTime){
			if(startTime > endTime){
				alert('开始时间大于结束时间');
				return false;
			}else{
				window.open('downloadExcel2.php?startTime='+startTime+'&endTime='+endTime+'&updater='+updater+'&cateid='+cateid);
			}
		}else{
			alert("时间不能为空");
			return false;
		}
	});
	//批量删除
	$(".piliangshanchu").click(function(){
		if(confirm("是否删除这些商品！")){
			var ids='';
			$("input[name=picSel]:checked").each(function() {
				ids+=$(this).val()+',';
				$(this).parents("tr").remove();
			});
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "ids="+ids+"&act=piliangshanchu",
				dataType: "html",
				success: function(date){
					//alert(date);
					
				}
			});
			//alert(ids);
		}
	});
});

</script>

<!-- jQuery Configuration -->
<script type="text/javascript" src="resources/scripts/simpla.jquery.configuration.js"></script>
<!-- Facebox jQuery Plugin -->
<script type="text/javascript" src="resources/scripts/facebox.js"></script>
<!-- jQuery WYSIWYG Plugin -->
<script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script>
<!-- jQuery my97datepicker -->
<script type="text/javascript" src="resources/scripts/My97DatePicker/WdatePicker.js"></script>
<!-- jQuery colorbox -->
<link rel="stylesheet" href="resources/css/colorbox.css" />
<script src="resources/scripts/colorbox/jquery.colorbox.js"></script>
<script type="text/javascript">
$(function($) {
	$(".group-pic").colorbox({rel:'group-pic',width:"50%", height:"75%"});
});
</script>
</head>
<body>
	<div id="body-wrapper">
	<!-- 分类 -->
	<span id="updatecatebyid_Html1">
	<select id="cate_id" name="cate_id" style="width: 325px;display: none;">
						<option value="" ></option>
						<?php foreach ($category as $keyY=>$itemY):?>
						<option class="cate-option-<?php echo $itemY['id'];?>" value="<?php echo $itemY['id'];?>" ><?php echo $itemY['cate'];?></option>
						<?php endforeach;?>
	</select></span>
	<span id="updatecatebyid_Html2">
	<select id="cate_id" name="cate_id" style="width: 325px;display: none;">
						<option value="" ></option>
						<?php foreach ($category99 as $keyY=>$itemY):?>
						<option class="cate-option-<?php echo $itemY['id'];?>" value="<?php echo $itemY['id'];?>" ><?php echo $itemY['cate'];?></option>
						<?php endforeach;?>
	</select></span>
	
	<!--  -->
	<?php if ($noAccess==1 || $noAccess==2):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，日期出错，该商品在这<span style="color: red;"><?php if ($noAccess==1) echo '之前';if ($noAccess==2) echo '之后';?></span>的15天已经上架。
			</div>
		</div>
	<?php endif;?>
	<?php if ($noAccess2==1):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，已被其他责任编辑选用。
			</div>
		</div>
	<?php endif;?>
	<?php if ($publishDateError):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，只能把时间改到今天或者之后，不能改到之前！
			</div>
		</div>
	<?php endif;?>
		<!-- Wrapper for the radial gradient background -->
		<a href="#messages" rel="modal" id="message_click"></a>
		<div id="messages" style="display: none;">
			<!-- Messages are shown when a link with these attributes are clicked: href="#messages" rel="modal"  -->

			<p style="">
				<strong>简短描述输入及修改</strong>
			</p>
			<form action="<?php echo $url."&page=".$page;?>" method="post">
				<fieldset>
					责任编辑：
					<select id="updater_2" name="updater_2" style="width: 300px;">
						<option value="" ></option>
						<?php foreach ($admins as $keyX=>$itemX):?>
						<option id="update-option-<?php echo $itemX['id'];?>" value="<?php echo $itemX['userName'];?>" <?php if($_SESSION['userName']==$itemX['userName']):?>selected="selected"<?php endif;?> ><?php echo $itemX['nickName'];?></option>
						<?php endforeach;?>
					</select><br />
					地址：
					<input class="text-input " type="text" id="goodsUrl" name="goodsUrl" style="width: 310px;"/><br />
					名称：
					<input class="text-input " type="text" id="title" name="title" style="width: 310px;"/><br />
					图片：
					<input class="text-input " type="text" id="pic_1" name="pic_1" style="width: 310px;"/><br />
					原价：
					<input class="text-input " type="text" id="originalPrice" name="originalPrice" style="width: 60px;"/>
					现价：
					<input class="text-input " type="text" id="currentPrice" name="currentPrice" style="width: 60px;"/>
					佣金：
					<input class="text-input " type="text" id="commission" name="commission" style="width: 60px;"/>%<br />
					分类：
					<span id="updatecatebyidHtml"></span><br />
					描述：
					<textarea class="textarea" id="description" name="description" cols="79" rows="5"></textarea>
					发布日期：
					<input class="text-input " type="text" id="publishDate" name="publishDate" onClick="WdatePicker()"/><br />
					<span>开始时间：
					<input class="text-input " type="text" id="startTime" name="startTime" value="" onClick="WdatePicker({startDate:'%y-%M-%d 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})"/> <br />
					</span>
					<span>结束时间：
					<input class="text-input " type="text" id="endTime" name="endTime" value="" onClick="WdatePicker({startDate:'%y-%M-%d 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})"/><br />
					</span>
					商品排序：
					<input class="text-input " type="text" id="sort" name="sort" value="1"/><br />
					已售数量：
					<input class="text-input " type="text" id="saledNum" name="saledNum" value=""/><br />
					<span id="taobao_img_span">
					</span>
					
					<input id="contentID" name="contentID" type="hidden" value="" />
					<input id="comefrom" name="comefrom" type="hidden" value="" />
					
					<input class="button" type="submit" value="修改" /> 
					<a href="javascript:void(0);" onclick="$(this).parents('#facebox').hide().siblings('#facebox_overlay').remove();">关闭</a>
				</fieldset>
			</form>
		</div>
		<!-- End #messages -->
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<!-- Page Head 
			<h2>欢迎使用<?php echo APPLICATION;?>管理后台</h2>-->
			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box
				<div class="content-box-header">
					<h3><?php echo WHAT;?>列表</h3>
					
					<div class="clear"></div>
				</div> -->
				<!-- End .content-box-header -->
				<div class="content-box-content">
				  <div style="background-color: #E4E4E4;padding-left: 10px;">
				    <div style="padding: 5px 0 0;">
					分类:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php if(empty($_GET['cateid'])): echo "全部";else:?><a href="<?php echo $url3;?>">全部</a><?php endif;?>
						<?php foreach ($category as $item):?>&nbsp;&nbsp;&nbsp;
						<?php if ($item['id']==$_GET['cateid']) : echo $item['cate'];else:?>
						<a href="<?php echo $url3;?>&cateid=<?php echo $item['id'];?>"><?php echo $item['cate'];?></a>
						<?php endif;endforeach;?>&nbsp;&nbsp;&nbsp;
						<?php if($_GET['cateid']=='9p9'): echo '9块9';else:?><a href="<?php echo $url3;?>&cateid=9p9">9块9</a><?php endif;?>
						<!-- <a href="list9point9.php<?php //echo $url3;?>">9块9</a> -->
						&nbsp;&nbsp;&nbsp;
						<!-- <a href="list19point9.php<?php //echo $url3;?>">19块9</a> -->
			        </div>
				    <div style="padding: 5px 0 0;">
					<form method="get" action="">
					
						商品ID：<input type="text" class="text-input" id="goodsid" name="goodsid" value="<?php echo $_GET['goodsid'];?>" size="12"/> 
						时间：
						<input type="text" class="text-input" id="startTime" name="startTime" onClick="WdatePicker()" value="<?php echo $_GET['startTime'];?>" size="10"/> 
						-
						<input type="text" class="text-input" id="endTime" name="endTime" onClick="WdatePicker()" value="<?php echo $_GET['endTime'];?>" size="10"/>
						&nbsp;&nbsp;&nbsp;责任编辑：
						<select id="updater" name="updater" style="">
							<option value="" ></option>
							<?php foreach ($admins as $keyX=>$itemX):?>
							<option id="" value="<?php echo $itemX['userName'];?>" <?php if($_GET['updater']==$itemX['userName']) echo 'selected="selected"';?>><?php echo $itemX['nickName'];?></option>
							<?php endforeach;?>
						</select>
						&nbsp;&nbsp;&nbsp;
						每页<input class="text-input" id="pagesize" name="pagesize" type="text" size="2" value="<?php echo $pagesize;?>"/>条
						&nbsp;&nbsp;&nbsp;
						<button class="button" id="zhixing" type="submit">搜索</button>
						<button class="button" id="download" type="submit">导出</button>						
						<input type="hidden" id="cateid" name="cateid" value="<?php echo $_GET['cateid'];?>"/>
						
					</form>
					</div>
					<div style="padding: 5px 0 5px;">
					今日上线 :
					<?php if(empty($_GET['cateid'])):echo "全部";else:?><a href="?startTime=<?php echo date("Y-m-d");?>&endTime=<?php echo date("Y-m-d");?>">全部<?php endif;?>(<?php echo $todayGoodsNum;?>)</a>
					<?php foreach ($category as $item):?>&nbsp;&nbsp;&nbsp;
						<?php if ($item['id']==$_GET['cateid']) : echo $item['cate'].'('.$item['num'].')';else:?>
						<a href="<?php echo $url4;?>&cateid=<?php echo $item['id'];?>&startTime=<?php echo date("Y-m-d");?>&endTime=<?php echo date("Y-m-d");?>"><?php echo $item['cate'].'('.$item['num'].')';?></a>
						<?php endif;endforeach;?>&nbsp;&nbsp;&nbsp;
						<a href="<?php echo $url4;?>&startTime=<?php echo date("Y-m-d");?>&endTime=<?php echo date("Y-m-d");?>&cateid=9p9">9块9<?php echo '('.$todayNPNNum.')';?></a>
						<!-- <a href="list9point9.php<?php //echo $url4;?>&startTime=<?php //echo date("Y-m-d");?>&endTime=<?php //echo date("Y-m-d");?>">9块9<?php //echo '('.$todayNPNNum.')';?></a>
						 -->&nbsp;&nbsp;&nbsp;
						<!-- <a href="list19point9.php<?php //echo $url4;?>&startTime=<?php //echo date("Y-m-d");?>&endTime=<?php //echo date("Y-m-d");?>">19块9<?php //echo '('.$todayNTPNNum.')';?></a> -->
					</div>
				  </div>
					<div class="clear"></div>
					<div class="tab-content default-tab" id="tab1">
						<!-- This is the target div. id must match the href of this div's tab -->

						<table>
							<thead>
								<tr>
									<td colspan="20">
										<!-- <div class="bulk-actions align-left">
											<button class="button piliangshanchu" >批量删除</button>
										</div> -->
										<?php if($maxPage>0):?>
										<div class="pagination">
											<a href="picList.php<?php echo $url;?>&page=1" title="First Page">&laquo; First</a>
											<a href="picList.php<?php echo $url."&page=".$pageInfo['previous'];?>" title="Previous Page">&laquo; Previous</a>
											<?php foreach ($pages as $item):?> 
											<a href="picList.php<?php echo $url."&page=".$item;?>" class="number <?php if($item == $page) echo 'current';?>" title="<?php echo $item;?>"><?php echo $item;?></a>
											<?php endforeach;?>
											<a href="picList.php<?php echo $url."&page=".$pageInfo['next'];?>" title="Next Page">Next &raquo;</a>
											<a href="picList.php<?php echo $url."&page=".$maxPage;?>" title="Last Page">Last &raquo;</a>
											total : <?php echo $maxPage;?>
										</div> 
										<?php endif;?>
										<!-- End .pagination -->
										<hr class="clear" />
									</td>
								</tr>
							</thead>
							<thead>
								<tr>
									<th><input class="check-all" type="checkbox" value="-1"/></th>
									<th>来源</th>
									<th>图片</th>
									<th>
										日期<br /><span ><a href="picList.php<?php echo $url2;?>&sort=publishDate_asc">
											<?php if($_GET['sort'] == "publishDate_asc"):?><img src="resources/images/sort3.png" />
											<?php else:?><img src="resources/images/sort1.png" /><?php endif;?>
											</a>
											<a href="picList.php<?php echo $url2;?>&sort=publishDate_desc">
											<?php if($_GET['sort'] == "publishDate_desc"):?><img src="resources/images/sort4.png" />
											<?php else:?><img src="resources/images/sort2.png" /><?php endif;?>
											</a>
										</span>
									</th>
									<th style="width: 6%;">标题</th>
									<th style="width: 10%;">描述</th>
									<th style="width: 10%;" class="taobao_url_css">地址</th>
									<th style="width: 6%;">原价</th>
									<th style="width: 6%;">现价</th>
									<th style="width: 6%;">佣金</th>
									<th style="">分类</th>
									<th>责任编辑<br /><span ><a href="picList.php<?php echo $url2;?>&sort=updater_asc">
											<?php if($_GET['sort'] == "updater_asc"):?><img src="resources/images/sort3.png" />
											<?php else:?><img src="resources/images/sort1.png" /><?php endif;?>
											</a>
											<a href="picList.php<?php echo $url2;?>&sort=updater_desc">
											<?php if($_GET['sort'] == "updater_desc"):?><img src="resources/images/sort4.png" />
											<?php else:?><img src="resources/images/sort2.png" /><?php endif;?>
											</a>
									</span></th>
									<th>收藏 /<br />开始时
									<!-- <br /><span ><a href="picList.php<?php echo $url2;?>&sort=collected_asc">
											<?php if($_GET['sort'] == "collected_asc"):?><img src="resources/images/sort3.png" />
											<?php else:?><img src="resources/images/sort1.png" /><?php endif;?>
											</a>
											<a href="picList.php<?php echo $url2;?>&sort=collected_desc">
											<?php if($_GET['sort'] == "collected_desc"):?><img src="resources/images/sort4.png" />
											<?php else:?><img src="resources/images/sort2.png" /><?php endif;?>
											</a> </span>-->
									</th>
									<th>入手/<br />结束时
									<!-- <br /><span ><a href="picList.php<?php echo $url2;?>&sort=shared_asc">
											<?php if($_GET['sort'] == "shared_asc"):?><img src="resources/images/sort3.png" />
											<?php else:?><img src="resources/images/sort1.png" /><?php endif;?>
											</a>
											<a href="picList.php<?php echo $url2;?>&sort=shared_desc">
											<?php if($_GET['sort'] == "shared_desc"):?><img src="resources/images/sort4.png" />
											<?php else:?><img src="resources/images/sort2.png" /><?php endif;?>
											</a> </span>-->
									</th>
									<th>点击</th>
									<th>排序</th>
									<th>已售</th>
									<th>操作</th>
									
								</tr>

							</thead>

							<tbody>
							<?php if(count($pictures)>0):?>
							<?php foreach ($pictures as $key=>$item):?>
								<tr>
									<td><input type="checkbox" name="picSel" value="<?php echo $item['id'];?>"/></td>
									<td><?php if($item['fromtable']=='JX') echo "精选";elseif ($item['fromtable']=='NPN') echo "9.9";else echo "error";?></td>
									<td>
										<p><a class="group-pic" href="<?php echo $item['picture'];?>">
											<img src="<?php echo "http://app100656353.imgcache.qzoneapp.com/app100656353/goodsimg/".$item['publishDate']."/".$item['goodsID'].".jpg";?>" onerror="this.src='<?php echo $item['picture']; ?>'" alt="" width="50px;" height="50px;"/>
										</a></p>
									</td>
									<td><?php echo $item['publishDate'];?></td>
									<td><?php echo $item['title'];?></td>
									<td><?php echo $item['desc'];?></td>
									<td><a href="<?php echo $item['goodsUrl'];?>" target="_blank"><?php echo $item['goodsID'];?></a></td>
									<td><?php echo $item['originalPrice'];?></td>
									<td><?php echo $item['currentPrice'];?></td>
									<td><?php if(!empty($item['commission'])) echo '<span>'.$item['commission'].'</span>%';?></td>
									<td><?php echo $item['catename'];?></td>
									<td><?php echo isset($item['nickName'])?$item['nickName']:$item['updater'];?></td>
									<td><?php if($item['fromtable']=='JX') echo $item['col_start']; else echo date("Y-m-d H:i:s",$item['col_start']);?></td>
									<td><?php if($item['fromtable']=='JX') echo $item['sha_end']; else echo date("Y-m-d H:i:s",$item['sha_end']);?></td>
									<td><?php echo $item['clickNum'];?></td>
									<td><?php echo $item['sort'];?></td>
									<td><?php echo $item['saledNum'];?></td>
									<td>
										<!-- Icons --> 
										<a  title="Edit" class="editbutton" data-id="<?php echo $item['id'];?>" data-fromtable="<?php echo $item['fromtable'];?>" style="cursor: pointer;">修改</a> <br /><br />
										<a  title="Del" class="delbutton" data-id="<?php echo $item['id'];?>" data-fromtable="<?php echo $item['fromtable'];?>"  style="cursor: pointer;">删除</a><br /><br />
										<a  title="Sale" class="isSalebutton" data-id="<?php echo $item['id'];?>" data-fromtable="<?php echo $item['fromtable'];?>"  data-status=<?php echo $item['status'];?> style="cursor: pointer;<?php if($item['status']==2) echo 'color: black;';?>"><?php if($item['status']==1) echo '上架中';if($item['status']==2) echo '下架中';?></a>
										<!-- <a href="#" title="Edit Meta"><img src="resources/images/icons/hammer_screwdriver.png" alt="Edit Meta" /></a> -->
									</td>
									
								</tr>
							<?php endforeach;?>
							<?php else:?>
								<tr style="font-size: 50px;text-align: center; font-weight: bold;"><td colspan="9" style="text-align: center;">没有<?php echo WHAT;?></td></tr>
							<?php endif;?>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="20">
										<!-- <div class="bulk-actions align-left">
											<button class="button piliangshanchu" >批量删除</button>
										</div> -->
										<?php if($maxPage>0):?>
										<div class="pagination">
											<a href="picList.php<?php echo $url;?>&page=1" title="First Page">&laquo; First</a>
											<a href="picList.php<?php echo $url."&page=".$pageInfo['previous'];?>" title="Previous Page">&laquo; Previous</a>
											<?php foreach ($pages as $item):?> 
											<a href="picList.php<?php echo $url."&page=".$item;?>" class="number <?php if($item == $page) echo 'current';?>" title="<?php echo $item;?>"><?php echo $item;?></a>
											<?php endforeach;?>
											<a href="picList.php<?php echo $url."&page=".$pageInfo['next'];?>" title="Next Page">Next &raquo;</a>
											<a href="picList.php<?php echo $url."&page=".$maxPage;?>" title="Last Page">Last &raquo;</a>
											total : <?php echo $maxPage;?>
										</div> 
										<?php endif;?>
										<!-- End .pagination -->
										<div class="clear"></div>
									</td>
								</tr>
							</tfoot>

						</table>

					</div>
					<!-- End #tab1 -->


				</div>
				<!-- End .content-box-content -->

			</div>
			<!-- End .content-box -->

			<div class="clear"></div>

			<div id="footer">
				<small> <!-- Remove this notice or replace it with whatever you want -->
					&#169; Copyright 2009 Your Company | Powered by <a
					href="http://themeforest.net/item/simpla-admin-flexible-user-friendly-admin-skin/46073">Simpla
						Admin</a> | <a href="#">Top</a>
				</small>
			</div>
			<!-- End #footer -->

		</div>
		<!-- End #main-content -->

	</div>
</body>


<!-- Download From www.exet.tk-->
</html>
